<template>
  <!--头部区域-->
  <el-header>
    <i :class="collapseIcon" style="font-size: 26px;" @click="handleCollapse"></i>
    <el-breadcrumb separator-class="el-icon-arrow-right" style="margin-left: 20px;">
      <el-breadcrumb-item>商品页面</el-breadcrumb-item>
      <el-breadcrumb-item>我的订单</el-breadcrumb-item>
      <el-breadcrumb-item>秒杀页面</el-breadcrumb-item>
    </el-breadcrumb>
    <div style="flex: 1; width: 0; display: flex; align-items: center;justify-content: flex-end;">
      <i class="el-icon-full-screen" style="font-size: 26px; cursor: pointer" @click="handleFull"></i>
      <el-dropdown placement="bottom">
        <div style="display: flex;align-items: center;cursor: default;">
          <img src="../assets/logo.png" width="40px" height="40px" style="margin: 0 5px;">
          <span>{{ user.name }}</span>
        </div>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item @click.native="modifyUser()">个人信息</el-dropdown-item>
          <el-dropdown-item @click.native="openDialog">修改密码</el-dropdown-item>
          <el-dropdown-item @click.native="logout">退出登录</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
      <user-view v-if="UserViewVisable" ref="UserView"></user-view>
      <password-form :dialog-visible.sync="showDialog"></password-form>
    </div>
  </el-header>
</template>

<script>
import UserView from "@/views/client/user/UserForm.vue"
import PasswordForm from "@/views/client/user/PasswordForm";

export default {
  name: "ClientHeaderView",
  data() {
    return {
      UserViewVisable: false,
      showDialog: false
    }
  },
  components: {
    UserView,
    PasswordForm
  },
  props: {
    //默认显示图标为收缩图标
    collapseIcon: String,
    //用户数据
    user: Object,
    //退出登录
    logout: Function,
    //控制菜单的左右收缩
    handleCollapse: Function,
  },

  methods: {
    //打开对话框
    openDialog() {
      this.showDialog = true
    },
    modifyUser() {
      this.UserViewVisable = true,
          this.$nextTick(() => {
            this.$refs.UserView.init()
          })
    },
    //控制屏幕状态
    handleFull() {
      if (!document.fullscreen) {
        document.documentElement.requestFullscreen()
      } else {
        document.exitFullscreen()
      }
    },
  },
}
</script>

<style>
@import "@/css/global.css";
</style>